package com.chinasoft.movies.mapper;

import com.chinasoft.movies.pojo.PopularityAndRevenue;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PopularityAndRevenueMapper {

    @Select("(SELECT title, popularity, revenue " +
            "FROM movies_top10_in_genre_by_popularity " +
            "WHERE genre = #{genre} AND rank_in_genre <= 10) " +
            "UNION " +
            "(SELECT title, popularity, revenue " +
            "FROM movies_top10_in_genre_by_revenue " +
            "WHERE genre = #{genre} AND rank_in_genre <= 10) " +
            "ORDER BY popularity DESC, revenue DESC")
    List<PopularityAndRevenue> queryPopAndRevByGenre(String genre);
}
